const mongoose = require('mongoose')

let DB_URL = 'mongodb://localhost:27017/menuServer'

mongoose.connect(DB_URL)
mongoose.connection.on('connected', () => {
    console.log('mongodb connect success')
})


const models = {
    base: {},
    user: {
        'name': { type: String, require: true },
        "phone": { type: Number },
        'qrcode': { type: String },
        'isSend': { type: Boolean }
    }
}

for (let m in models) {
    mongoose.model(m, new mongoose.Schema(models[m]))
}

module.exports = {
    getModel: function(name) {
        return mongoose.model(name)
    }
}